package notification.net;
import java.util.LinkedList;

class block{
  public final short Type;
  public final int Size;
  public final byte Hide;
  public final byte TypeValue;
  public final String Name;
  public final Object Value;
  @SuppressWarnings("rawtypes")
  public final Class ClassValue;
  
  public String toString(){
	  return "Type block's=="+Type+"\nSize of block=="+Size+"\nAtributs of hide=="+Hide+
			  "\nName block=="+Name+"\nValues=="+Value+"\n";
  }
  
  @SuppressWarnings("rawtypes")
public block(short Type, int Size, byte Hide, byte TypeValue, String Name, Object Value, Class ClassValue){
	  this.Type=Type;
	  this.Size=Size;
	  this.Hide=Hide;
	  this.TypeValue=TypeValue;
	  this.Name=Name;
	  this.Value=Value;
	  this.ClassValue=ClassValue;
  }
}

class posinfo{
  public final double Lon;
  public final double Lat;
  public final double Altitude;
  public final short Speed;
  public final short Course;
  public final byte CountSatellites;
  public posinfo(double lon, double lat, double altitude, short speed, short cource, byte countSatellites){
	  Lon=lon;
	  Lat=lat;
	  Altitude=altitude; 
	  Speed=speed;
	  Course=cource; 
	  CountSatellites=countSatellites;
  }
  public String toString(){
	return "longitude=="+Lon+"\nlatitude=="+Lat+"\nAltitude=="+Altitude+"\nSpeed=="+Speed+
			"\nCourse=="+Course+"\nCount Satellites=="+CountSatellites+"\n";  
  }
}

public class MessageWialon {
	public final int SizeMessage;
	public final String IDcontroller;
	public final int time;
	public final int flag;
	
	public final LinkedList<block> bloks=new LinkedList<block>();
	
	public MessageWialon(int Size, String ID, int t, int fl){
		SizeMessage=Size;
		IDcontroller=ID;
		time=t;	
		flag=fl;
	}

	@SuppressWarnings("rawtypes")
	public Class CAST(byte typeval){
		switch(typeval){
		 case 0x1: return String.class;
		 case 0x2: return posinfo.class;
		 case 0x3: return Integer.TYPE;
		 case 0x4: return Double.TYPE;
		 case 0x5: return Long.TYPE;
		}
		return null;
	}
	
	public String toString(){
		String ret="";
		ret+="Size message=="+SizeMessage+"\nID of the controller=="+IDcontroller+"\nTime=="+time+"\nflag=="+flag
				+"\n\nBlocks of data:\n\n";
		for (block i: bloks) ret+=i+"\n";
		return ret;	
	}

}
